function [frac_sold_state,sale_price_state,th,et,Vb] = ds_urn_matching_one_price_static_buyerV(params,State,num_buyers,num_sellers_state,kw,w_mat,Vb_guess)
% num_sellers = Ne.*dist
% num_buyers is a 1 by 9 for each aggregate state 

lamb_1(2) = params(1); % this was missing was 0.1
lamb_1(3) = params(2);
lamb_2 = params(3);
lamb_1(1) = 1;
c_b = params(4);

lamb_1 = lamb_1(State(4,:));
gamm = 0.5;

M_data = xlsread('data_for_model/save_calibrationcontall_experience_l1', 'bust'); 
v(1) = M_data(14,1)/gamm;
M_data = xlsread('data_for_model/save_calibrationcontall_experience_l1', 'medium'); 
v(2) = M_data(14,1)/gamm;
M_data = xlsread('data_for_model/save_calibrationcontall_experience_l1', 'boom'); 
v(3) = M_data(14,1)/gamm;
    
lamb_vec_fun = @(e)lamb_1.*e.^lamb_2;
lamb_vec = lamb_vec_fun(State(1,:));
eta      = @(th)(1./th).*(1 - exp(-lamb_vec.*th)); % buyer match rate
mu       = @(th)1 - exp(-lamb_vec.*th); % seller match rate
v        = v(State(4,:));

%% guess buyer value change (c_b is really c_b + V_b)
Vb = Vb_guess; % computing buyer value for each state
found=0;
sale_price_state = gamm*v;
iter = 0;

while found==0 & iter<200
    iter = iter+1;
    %% Solution with one shot search with no price setting
    et = (c_b+Vb(State(3,:)))./(v-sale_price_state);
    fun = @(th)1./th.*(1-exp(-lamb_vec.*th))-et; % function
    x0 = 1*ones(size(et)); % initial interval
    options = optimset('Display','off');
    th = fsolve(fun,x0,options);
    num_b_state = num_sellers_state.*th;
    num_buyers_tomatch = sum(repmat(num_b_state',1,kw).*w_mat);
    if max(abs(num_buyers_tomatch-num_buyers))<1
        found=1;
    else
        Vb = (Vb + c_b).*(1+(num_buyers_tomatch-num_buyers)./(100*num_buyers))-c_b;
    end
end

%% Statistics
frac_sold_state = mu(th); % sale probability



